package com.lucene.blog.util;

import org.apache.shiro.crypto.hash.Md5Hash;

/**
 * MD5加密工具类
 * @author yachao
 *
 */
public class CryptographyUtil {
	
	/**
	 * 使用shiro的MD5加密
	 * @param str
	 * @param salt
	 * @return
	 */
	public static String md5(String str, String salt) {
		// Md5Hash是Shiro的一个方法
		return new Md5Hash(str, salt).toString();
	}
	
	public static void main(String[] args) {
		String password = "admin";
		String crypto = CryptographyUtil.md5(password, "javacoder");
		System.out.println("Md5加密: " + crypto + "/length: " + crypto.length());
	}
}
